package com.homer.android.sdk.db.greenrobot.daos;

import java.util.List;





import com.homer.android.sdk.object.db.IUserDB;

import de.greenrobot.dao.DaoException;

public class UserDB implements IUserDB
{
    
    private long id;
    
    /** Not-null value. */
    private String phone;
    
    /** Not-null value. */
    private String key;
    
    /** Not-null value. */
    private String name;
    
    private boolean isLastLogin;
    
    /** Used to resolve relations */
    private transient DaoSession daoSession;
    
    /** Used for active entity operations. */
    private transient UserDBDao myDao;
    
    private List<DeviceDB> devices;
    
    // KEEP FIELDS - put your custom fields here
    // KEEP FIELDS END
    
    public UserDB()
    {
    }
    
    public UserDB(long id)
    {
        this.id = id;
    }
    
    public UserDB(long id, String phone, String key, String name, boolean isLastLogin)
    {
        this.id = id;
        this.phone = phone;
        this.key = key;
        this.name = name;
        this.isLastLogin = isLastLogin;
    }
    
    /** called by internal mechanisms, do not call yourself. */
    public void __setDaoSession(DaoSession daoSession)
    {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getUserDBDao() : null;
    }
    
    public long getId()
    {
        return id;
    }
    
    public void setId(long id)
    {
        this.id = id;
    }
    
    /** Not-null value. */
    public String getPhone()
    {
        return phone;
    }
    
    /** Not-null value; ensure this value is available before it is saved to the database. */
    public void setPhone(String phone)
    {
        this.phone = phone;
    }
    
    /** Not-null value. */
    public String getKey()
    {
        return key;
    }
    
    /** Not-null value; ensure this value is available before it is saved to the database. */
    public void setKey(String key)
    {
        this.key = key;
    }
    
    /** Not-null value. */
    public String getName()
    {
        return name;
    }
    
    /** Not-null value; ensure this value is available before it is saved to the database. */
    public void setName(String name)
    {
        this.name = name;
    }
    
    public boolean getIsLastLogin()
    {
        return isLastLogin;
    }
    
    public void setIsLastLogin(boolean isLastLogin)
    {
        this.isLastLogin = isLastLogin;
    }
    
    /**
     * To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted,
     * make changes to the target entity.
     */
    public List<DeviceDB> getDevices()
    {
        if (devices == null)
        {
            if (daoSession == null)
            {
                throw new DaoException("Entity is detached from DAO context");
            }
            DeviceDBDao targetDao = daoSession.getDeviceDBDao();
            List<DeviceDB> devicesNew = targetDao._queryUserDB_Devices(id);
            synchronized (this)
            {
                if (devices == null)
                {
                    devices = devicesNew;
                }
            }
        }
        return devices;
    }
    
    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    public synchronized void resetDevices()
    {
        devices = null;
    }
    
    /** Convenient call for {@link AbstractDao#delete(Object)}. Entity must attached to an entity context. */
    public void delete()
    {
        if (myDao == null)
        {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }
    
    /** Convenient call for {@link AbstractDao#update(Object)}. Entity must attached to an entity context. */
    public void update()
    {
        if (myDao == null)
        {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }
    
    /** Convenient call for {@link AbstractDao#refresh(Object)}. Entity must attached to an entity context. */
    public void refresh()
    {
        if (myDao == null)
        {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);    }

	
    
}

